package Collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 *
 */
public class StreamDemo3 {
    public static void main(String[] args) {

        List<List<String>> list = new ArrayList<>();
        list.add(Arrays.asList(new String[]{"one","two","three"}));
        list.add(Arrays.asList(new String[]{"four","five","six"}));
        list.add(Arrays.asList(new String[]{"seven","eight"}));
        System.out.println(list);

        /*
            需求:将集合中的所有集合元素全部取出,形成一个集合即可
            将二维集合降成一维集合
            [[one, two, three], [four, five, six], [seven, eight]]
            [one, two, three, four, five, six, seven, eight]
         */

        List<String> list2 = list.stream().flatMap(e->e.stream()).collect(Collectors.toList());
        System.out.println(list2);


    }
}
